<?php
class Frontend_Form_User_Base extends Zend_Form
{
    public function init()
    {
        // add path to custom validators
        $this->addElementPrefixPath(
            'Custom_Validate',
            APPLICATION_PATH . '/../lib/Custom/Validate/',
            'validate'
        );

        $translator = self::$_translatorDefault;

        $this->addElement('text','name',array(
            'filters'       => array('StringTrim','StringToLower'),
            'validators'    => array(
                'Alpha',
                array('StringLength',true,array(3,16)),
                array('UniqueName', false, array(Wenda::getModel('User'))),
            ),
            'required'      => true,
            'label'         => $translator->translate('username'),
        ));

        $this->addElement('password', 'password', array(
            'filters'       => array('StringTrim','StringToLower'),
            'validators'    => array(
                array('StringLength', true, array(6,20))
            ),
            'required'      => true,
            'label'         => $translator->translate('password')
        ));

        $this->addElement('password','passwordVerify',array(
            'filters'       => array('StringTrim','StringToLower'),
            'validators'    => array('PasswordVerify'),
            'required'      => true,
            'label'         => $translator->translate('password verify'),
        ));

        $this->addElement('text', 'email', array(
            'filters'    => array('StringTrim', 'StringToLower'),
            'validators' => array(
                array('StringLength', true, array(3, 128)),
                array('EmailAddress'),
                array('UniqueEmail', false, array(Wenda::getModel('User'))),
            ),
            'required'   => true,
            'label'      => $translator->translate('email'),
        ));

        $this->addElement('submit', 'submit', array(
            'required'   => false,
            'ignore'     => true,
            'attribs'    => array('class' => 'button'),
        ));

         $this->addElement('hidden', 'userId', array(
            'filters'    => array('StringTrim'),
            'required'   => true,
            'decorators' => array('viewHelper',array('HtmlTag', array('tag' => 'dd', 'class' => 'noDisplay')))
        ));

    }
}
